#!/bin/bash

base_path=$(cd $(dirname $0); pwd)


function backup {
    local prog_file=$base_path/backup.py
    local log_file=$base_path/../log/backup.log
    local ct="0 0 * * * python $prog_file &>> $log_file"
    crontab -l|grep -q $prog_file || {
        crontab -l > /tmp/crontab.tmp
        echo "$ct" >> /tmp/crontab.tmp
        cat /tmp/crontab.tmp|crontab
        rm -f /tmp/contab.tmp
    }
    echo "backup ct installed."
    crontab -l|grep $prog_file
}

backup
